package com.rmt.www.daoImpl;

import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;

import com.rmt.www.dao.DesignArtifactHistoryDao;
import com.rmt.www.vo.DesignArtifactHistory;
import com.rmt.www.vo.History;
import com.rmt.www.vo.TestArtifactHistory;

public class DesignArtifactHistoryDaoImpl implements DesignArtifactHistoryDao {

	private JdbcTemplate jdbcTemplate;

	public void setDataSource(DataSource dataSource) {
		this.jdbcTemplate = new JdbcTemplate(dataSource);
	}
	
	@SuppressWarnings("unchecked")
	public List<DesignArtifactHistory> getDesignArtifactHistoriesByAId(int aid) {
		return (List<DesignArtifactHistory>)(this.jdbcTemplate.query("select * from designartifacthistory where designartifactid=?",
				new Object[]{aid}, 
				new int[]{java.sql.Types.INTEGER}, 
				new DesignArtifactHistoryRowMapper()));
	}

	public void insertDesignArtifactHistory(DesignArtifactHistory history) {
		jdbcTemplate.update("insert into designartifacthistory(title,architect,consideration,input,function,output,perfrequest,securityrequest,storagerequest,innerinterface,outerinterface,pid,priority,effort,cost,risk,comment,createrid,createdtime,updaterid,updatedtime,version,status,updatedtimes,designartifactid)"+
				"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", 
				new Object[] {
				history.getTitle(),
				history.getArchitect(),
				history.getConsideration(),
				history.getInput(),
				history.getFunction(),
				history.getOutput(),
				history.getPerfrequest(),
				history.getSecurityrequest(),
				history.getStoragerequest(),
				history.getInnerinterface(),
				history.getOuterinterface(),
				history.getPid(),
				history.getPriority(),
				history.getEffort(),
				history.getCost(),
				history.getRisk(),
				history.getComment(),
				history.getCreaterid(),
				history.getCreatedtime(),
				history.getUpdaterid(),
				history.getUpdatedtime(),
				history.getVersion(),
				history.getStatus(),
				history.getUpdatedtimes(),
				history.getDesignartifactid()
		}, 	new int[] {
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.INTEGER,
				java.sql.Types.VARCHAR,
				java.sql.Types.INTEGER,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.TIMESTAMP,
				java.sql.Types.INTEGER,
				java.sql.Types.TIMESTAMP,
				java.sql.Types.VARCHAR,
				java.sql.Types.VARCHAR,
				java.sql.Types.INTEGER,
				java.sql.Types.INTEGER
		});
	}

}
